//
//  SocialViewCell.m
//  LStyle
//
//  Created by Obaid Abdul Maroof on 12/16/09.
//  Copyright 2009 Vrije University. All rights reserved.
//

#import "SocialViewCell.h"

#define IMAGE_LOCATION @"http://lstyle.com/upload/nightlife/%7BM0K80D-M7MX-9RZY-7DWT3V%7D/%7BM0K80D-M7MX-9RZY-7DWT3V%7D.jpg"
@implementation SocialViewCell

- (id)initWithFrame:(CGRect)aRect reuseIdentifier:(NSString *)identifier{
	if (self = [super initWithFrame:aRect reuseIdentifier:identifier])
	{
		// turn off selection use
		self.selectionStyle = UITableViewCellSelectionStyleGray;
		
		CGSize size = aRect.size;
		
		size.width = (size.width/4); 
		CGRect tempRect = aRect;
		tempRect.size = size;
		
		UIImage *img = [[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: IMAGE_LOCATION]]] retain];
		imgImage = [[UIImageView alloc] initWithFrame:CGRectMake(5, 3, tempRect.size.width, tempRect.size.height-5)];
		imgImage.image = img;
		
		
		lblFirst = [[UILabel alloc] initWithFrame:CGRectMake(tempRect.size.width + 5, 3, aRect.size.width - tempRect.size.width - 10 , 20)];
		lblSecond = [[UILabel alloc] initWithFrame:CGRectMake(tempRect.size.width + 5, 40, aRect.size.width - tempRect.size.width - 10 , 20)];
		
		lblFirst.text = @"LIFE BALL 2009";
		lblSecond.text = @"Vienna";
		
		UIFont *fnt = [UIFont fontWithName:@"Verdana" size: 14.0];
		lblFirst.font = fnt;
		lblSecond.font = [UIFont fontWithName:@"Verdana" size:10];
		
		[self.contentView addSubview:imgImage];
		[self.contentView addSubview:lblFirst];
		[self.contentView addSubview:lblSecond];
	}
    
	return self;
}


- (void)layoutSubviews
{
	[super layoutSubviews];
	CGRect rect = [self.contentView bounds];
	CGRect rect2 = [self.contentView bounds];
	CGSize size = rect.size;
	CGSize size2 = size;
	
	rect.origin.x = 3;
	rect.origin.y = 5;
	size.width = (size.width/4);
	size.height -= 10;
	rect.size = size;
	
	imgImage.frame = rect;	
	

	rect.origin.y -= 5;
	rect.origin.x = 10 + imgImage.frame.size.width;
	size.width = rect2.size.width - size.width - 10;
	size.height = 20;
	rect.size = size;	
	
	lblFirst.frame = rect;
	rect.origin.y = 35;
	lblSecond.frame = rect;
	
	
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)dealloc {
    [super dealloc];
}


@end
